<?php

namespace Modules\Agent\Http\Controllers\Admin\V1;

use Illuminate\Http\Request;
use Illuminate\Routing\Controller;

use \Modules\Agent\Entities\InviteRecord;

use Validator;
use ThrowException;
use Auth;

class InviteRecordController extends Controller
{
    // 各种状态的数量统计
    public function statusTotal(Request $req)
    {
        $rule = [
        ];
        Validator::make($req->all(), $rule)->fails() && ThrowException::BadRequest();
        $total = [
            'all' => InviteRecord::where('id', '>', 0)->count(),
        ];

        return [
            'total' => $total
        ];
    }

    public function index(Request $req)
    {
        $rule = [
        ];

        Validator::make($req->all(), $rule)->fails() && ThrowException::BadRequest();

        $options = $req->all();
        $options['with'] = ['user', 'direct_inviter', 'indirect_inviter'];

        $list = InviteRecord::getList($options);

        return $list->generateListResponse();
    }

}
